package top.chukongxiang.monitorservice.tools;

import top.chukongxiang.monitorservice.config.JnaConfiguration;
import top.chukongxiang.monitorservice.config.listener.ContextRefreshedListener;
import top.chukongxiang.monitorservice.jna.HCNetSDK;
import top.chukongxiang.monitorservice.service.HcNetSdkService;

/**
 * @author 楚孔响
 * @version 1.0
 * @date 2023/10/26 16:58
 */
public class FxBeanUtil {

    private static JnaConfiguration jnaConfiguration;

    private static HCNetSDK hcNetSDK;

    private static HcNetSdkService hcNetSdkService;

    public static HCNetSDK getHcNetSdk() {
        if (hcNetSDK != null) {
            return hcNetSDK;
        }
        hcNetSDK = getJnaConfiguration().hcNetSdk();
        if (!ContextRefreshedListener.sdkInitialed) {
            hcNetSDK.NET_DVR_Init();
            ContextRefreshedListener.sdkInitialed = true;
        }
        return hcNetSDK;
    }

    public static HcNetSdkService getHcNetSdkService() {
        if (hcNetSdkService != null) {
            return hcNetSdkService;
        }
        hcNetSdkService = new HcNetSdkService(getHcNetSdk());
        return hcNetSdkService;
    }

    public static JnaConfiguration getJnaConfiguration() {
        if (jnaConfiguration != null) {
            return jnaConfiguration;
        }
        jnaConfiguration = new JnaConfiguration();
        return jnaConfiguration;
    }

    public static void updateSdkFolder() {
        getJnaConfiguration().updateSdkFolder();
    }


}
